package patten.xingwei.observer.demo2;

import java.util.ArrayList;
import java.util.List;

/**
 * Description：TODO
 * Author：zwenzhi
 * Date：2023/11/17 14:12
 */
public class RoomDateSubject implements RoomSubject{
    private List<SensorObserver> sensorObserverList = new ArrayList<>();
    private String temperature;
    private String humidity;
    private String pressure;
    @Override
    public void addObserver(SensorObserver sensorObserver) {
        this.sensorObserverList.add(sensorObserver);
    }

    @Override
    public void removeObserver(SensorObserver sensorObserver) {
        this.sensorObserverList.remove(sensorObserver);
    }

    @Override
    public void notifyObserver() {
        for (SensorObserver sensorObserver : this.sensorObserverList) {
            sensorObserver.update(this);
        }
    }

}
